/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bayu.common.lib;

import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;

/**
 *
 * @author Bayu
 */
public class CommonUtil {
    public static String[] monthName = {"January", "February",
            "March", "April", "May", "June", "July",
            "August", "September", "October", "November",
            "December"};

     public static String[] shortMonthName = {"Jan", "Feb",
            "Mar", "Apr", "May", "Jun", "Jul",
            "Aug", "Sep", "Oct", "Nov",
            "Dec"};
    public String getPathClass(){

       Class cls = this.getClass();
       ProtectionDomain pDomain = cls.getProtectionDomain();
       CodeSource cSource = pDomain.getCodeSource();
       URL loc = cSource.getLocation();
       return loc.getPath().substring(1, loc.getPath().length());
    }

    public static String getMonthName(int index){
         return monthName[index];
    }

    public static String getShortMonthName(int index){
         return shortMonthName[index];
    }

    public static String formatStringDate(String str){
        String[] tempStr = str.split("-");
        String month = getMonthName(Integer.parseInt(tempStr[1])-1);
        String hasil = tempStr[2]+" "+month+" "+tempStr[0];

        return hasil;
    }

    public static int getCurrentMonth(){
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        return calendar.get(java.util.Calendar.MONTH)+1;

    }

    public static int getCurrentYear(){
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        return calendar.get(java.util.Calendar.YEAR);

    }
}
